package com.rd.student.jiaji.class4.suyan.zrrd.homework2;

import java.util.Arrays;
import java.util.Random;

public class 作业练习第二种方法 {
    public static void main(String[] args) {
        int[] arr=new int[5];
        int index=0;
        Random random=new Random();
        while (true){
            int a=random.nextInt(35)+1;
            if (index==0){
                arr[index]=a;
                index++;

            }else {int result=0;
                for (int i=0;i<index;i++){
                    if (arr[i]==a){

                        result=1;
                    }
                }
                if (result==0){
                    arr[index]=a;
                    index++;
                }
                if (index==5){
                    break;
                }

            }
        }
        System.out.println(Arrays.toString(arr));
        doublecolor();
    }
    public static void doublecolor() {
        boolean[] color = new boolean[35];
        int index = 0;
        int[] red = new int[5];
        Random random = new Random();
        for (; ; ) {
            int a = random.nextInt(35);
            if (!color[a]) {
                red[index] = a;
                index++;
            }
            if (index == 5) {
                break;
            }
        }
        System.out.println(Arrays.toString(red));
    }
    }
